<%-- 
    Document   : Giohang
    Created on : Dec 28, 2013, 1:15:47 AM
    Author     : Welcome
--%>

<%@page import="businesscard.DAO.GiohangDAO"%>
<%@page import="businesscard.DAO.UserDAO"%>
<%@page import="bc.entity.User"%>
<%@page import="bc.entity.Giohang"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script>
            
        </script>
    </head>
    <body>
        <h1>Giỏ hàng!</h1>
        <% 
            //Giohang gh=(Giohang)session.getAttribute("giohang");
            //if(gh==null){
                 HttpSession session1 = request.getSession();
                User usr = (User) session1.getAttribute("USER");
                 String username = usr.getUser();
                UserDAO userDAO1 = new UserDAO();
                User user5 = userDAO1.getUser2(username);
                int id_user = user5.getIdUser();
                GiohangDAO ghDAO=new GiohangDAO();
               Giohang[] gh=ghDAO.getAllGiohang(id_user);
               if(gh!=null){
                   
        %>
        <div class="tabledetail">
                    <table align="center" border="1" width="500px">
                    <tr>
                        <th>STT</th>
                        <th>Tên liên hệ</th>
                        <th>Đơn giá</th>          
                    </tr>
                    <% 
                    int tongtien=0;
                        for(int i=0;i<gh.length;i++){
                            String ten=gh[i].getLienhe().getTen();
                            int tien=gh[i].getTongtien();
                            tongtien+=tien;
                    %>
                    <tr>
                            <td><%=i+1%></td>
                            <td><%=ten%></td>                            
                            <td><%=tien%>VND</td>        
                             <input type="hidden" name="idbook" value="<%%>"/>
                            <td>

                              <form action="CartController" method="get">
                                    <input type="hidden" name="action" value="trahang"/>
                                    <input type="hidden" name="idbook" value="<%%>"/>
                                    <input class="button" type="submit" value="Xoá"/>
                                </form> 
                            <%--  <a onclick="xoasp(<%= ms %>)">Xoá</a>--%>
                            </td>
                        </tr>
                        <% }%>
                        <tr>
                            <td align="right" colspan="6" ><b>Tổng tiền:&nbsp;<%=tongtien%>VND</b></td>
                    </tr>
                      </table>  
                      <span id="textcart"> <a href="index.jsp"> <<< Mua thêm</a></span> 
                       <span id="textthanhtoan"><button id="thanhtoan">Thanh toán >>></button></span>
                    </table>
        </div>
                    <div id="txtThanhtoan"></div>
                      <% } %>
    </body>
</html>
